package gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import model.Model;

public class TopPanel extends JPanel{

	private static final long serialVersionUID = 1L;
	JTextArea textArea;
	JScrollPane scrollText;
	ButtonPanel buttons;
	
	public TopPanel(Model model) {
		setLayout(new BorderLayout());
		textArea = new JTextArea(20, 600);
		textArea.setEditable(false);
		textArea.setFont(new Font("Courier", Font.PLAIN, 12));
		add(textArea, BorderLayout.CENTER);
		scrollText = new JScrollPane(textArea);
		setPreferredSize(new Dimension(800, 600));
		
		buttons = new ButtonPanel(model, this);
		
		add(scrollText, BorderLayout.CENTER);	
		add(buttons, BorderLayout.SOUTH);
	}
	
	public void addText(String text){
		textArea.append(text);
		//textArea.revalidate();
	}
	
	@Override
	public void revalidate(){
		super.revalidate();
		if(textArea!=null){
			textArea.revalidate();
		}
		if(scrollText!=null){
			scrollText.revalidate();
		}
		if(buttons!=null){
			buttons.revalidate();
		}
	}
	
}


